package com.tuanzi.loan.business.service.family.impl;

import com.tuanzi.loan.business.entity.family.LoanUnionForeignChannelInfo;
import com.tuanzi.loan.business.repository.family.LoanUnionForeignChannelInfoRepository;
import com.tuanzi.loan.business.service.family.LoanUnionForeignChannelInfoService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.family.LoanUnionForeignChannelInfoRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * User: liangZongXi
 * Create time: 17:18 2018/11/19
 * Description:
 */

@Debug
@Service
@Transactional
@Retryable(value = { RetryException.class })
public class LoanUnionForeignChannelInfoServiceImpl implements LoanUnionForeignChannelInfoService {

    private final LoanUnionForeignChannelInfoRepository loanUnionForeignChannelInfoRepository;

    @Autowired
    public LoanUnionForeignChannelInfoServiceImpl(LoanUnionForeignChannelInfoRepository loanUnionForeignChannelInfoRepository) {
        this.loanUnionForeignChannelInfoRepository = loanUnionForeignChannelInfoRepository;
    }

    @Override
    public Page<LoanUnionForeignChannelInfo> list(PageSearcher<LoanUnionForeignChannelInfoRequest> pageSearcher) {
        return loanUnionForeignChannelInfoRepository.list(pageSearcher.getSearchCondition(), pageSearcher.getPageable());
    }

    @Override
    public LoanUnionForeignChannelInfo findByChannelIdAndActivityId(Integer channelId, String activityId) {
        return loanUnionForeignChannelInfoRepository.findByChannelIdAndActivityId(channelId, activityId);
    }

    @Override
    public LoanUnionForeignChannelInfo save(LoanUnionForeignChannelInfo info) {
        return loanUnionForeignChannelInfoRepository.save(info);
    }
}
